home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATATYPE.SWG / 0007_SAVEDATA.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  45 lines

  1. {
  2. >I have a question about Typed Constants.  By this I mean the
  3. >following declaration:
  4. >
  5. >  Const
  6. >    Example : Byte = 1;
  7. >
  8. >What are the advantages to this?
  9.  
  10.   ...One of the advantages to using "Typed Constants", is that it
  11.   allows you to initalize Variables at CompILE-TIME (ie: When you
  12.   Compile your source-code into an .EXE), instead of RUN-TIME.
  13.   (ie: When your Program is actually running.)
  14.  
  15.   ...Another advantage is that "Typed Constants" within Functions/
  16.   Procedures keep their data between calls.
  17. }
  18.  
  19. Procedure SaveData({input} Var DataBuffer : byar_Data);
  20. Const
  21.   bo_FileOpen : Boolean = False;
  22. begin
  23.   if (bo_FileOpen = False) then
  24.     begin
  25.       assign(fi_Data, st_DataName);
  26.       {$I-}
  27.       reset(fi_Data, 1);
  28.       {$I+}
  29.       Check_For_IO_Error;
  30.       bo_FileOpen := True
  31.     end;
  32.   blockWrite(fi_Data, DataBuffer, sizeof(DataBuffer));
  33.   Check_For_IO_Error
  34. end;
  35.  
  36. {
  37.   ...The Procedure above would only open the data-File once,
  38.   and all Repeat calls to this Procedure would just Write
  39.   there data to the File. (ie: The Boolean "Typed-Constant"
  40.   bo_FileOpen would only be False the first time this routine
  41.   executed. The next time this routine executed bo_FileOpen
  42.   would be equal to True.)
  43. }
  44.  
  45.